package com.situ.mall.web.controller;

import com.situ.mall.common.entity.Attachment;
import com.situ.mall.common.entity.Product;
import com.situ.mall.common.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

//主页展示的商品
@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;

    @GetMapping("/{id}")
    public String product(@PathVariable Integer id, Model model){
//        根据ID查商品
        Product p = productService.getById(id);
//        用Model给它带过去
        model.addAttribute("product",p);

        return "detail";
    }

}
